package com.purchase.order.controller;

import com.purchase.common.annotation.Log;
import com.purchase.common.core.controller.BaseController;
import com.purchase.common.core.domain.AjaxResult;
import com.purchase.common.core.page.TableDataInfo;
import com.purchase.common.enums.BusinessType;
import com.purchase.manage.damian.OrderList;
import com.purchase.order.domain.DAO.EvaluateDTO;
import com.purchase.order.domain.OrderEvaluate;
import com.purchase.order.service.IEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.rmi.ServerException;
import java.util.List;

/**
 * @author oyi46
 * @version 1.0
 * Create by 2023/7/11 14:33
 */

@RestController
@RequestMapping("/evaluate")
public class EvaluateController extends BaseController {
    //生成连接未测试

    @Autowired
    IEvaluateService evaluateService;

    @PreAuthorize("@ss.hasPermi('purchase:purchase:insert')")
    @Log(title = "查看所有等待确认的订单 ", businessType = BusinessType.INSERT)
    @GetMapping("/list")
    public TableDataInfo isOverList(OrderEvaluate evaluate) {
        startPage();
        List<OrderList> list = evaluateService.selectOrderList(evaluate);
        return getDataTable(list);
    }

    @Log(title = "填写评价表 ", businessType = BusinessType.INSERT)
    @PostMapping("/orderover")
    public AjaxResult priceComparison(@RequestBody OrderEvaluate evaluate) throws ServerException {
        return success(evaluateService.insertEvaluate(evaluate));
    }

    @PreAuthorize("@ss.hasPermi('purchase:purchase:insert')")
    @Log(title = "评价表 列表", businessType = BusinessType.SELECT)
    @GetMapping("/evaluatelist")
    public TableDataInfo evaluateList(OrderEvaluate evaluate){
        startPage();
        List<EvaluateDTO> list = evaluateService.selectList(evaluate);
        return getDataTable(list);
    }
}
